package demo4.controller;

import demo4.mapper.IUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Scanner;
@Component
public class UserController {
	@Autowired
	private IUserMapper userMapper;
	
	public void start() {
		System.out.println("请输入操作序号");
		Scanner scanner = new Scanner(System.in);
		System.out.println("1.注册");
		System.out.println("2.登录");
		System.out.println("3.修改密码");
		System.out.println("4.用户列表");
		int num = scanner.nextInt();
		switch (num) {
		case 1:
			regUser();
			break;
		case 2:
			System.out.println("登录");
			break;
		case 3:
			System.out.println("修改密码");
			break;
		case 4:
			System.out.println("用户列表");
			break;
		default:
			System.out.println("输入错误");
			break;
		}
		scanner.close();
	}
	
	private void regUser() {
		System.out.println("欢迎注册");
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入用户名:");
		String username =  scanner.nextLine();
		System.out.println("请输入密码:");
		String password = scanner.nextLine();
		System.out.println("请输入昵称:");
		String nickname = scanner.nextLine();
		System.out.println("请输入年龄:");
		int age = scanner.nextInt();
		
		int result = userMapper.insertUser();
	}
}
